<?php

/**
 *	@name Factory
 *	@copyright : SMART - ULg (www.smart.ulg.ac.be)		
 *
**/


/**
 * Class Factory : 
 * general Factory for Projects, tasks, ...
 * 
 * $Rev$ 
 * $LastChangedRevision$
 * $LastChangedBy$
 * $LastChangedDate$
 * $HeadURL$
 *
 * @name ProjectsListBroker
 * @package webservices/broker
 * @author : JPh HUMBLET
 * @copyright : SMART - ULg (www.smart.ulg.ac.be)
 * @category : ExAMS::Core
 *
**/


require_once("../classes/project/Project.php");
require_once("../classes/project/Tasks.php");
require_once("../classes/tracking/TimeSheet.php");


class Factory
{
	
	/**
	 * buildFromFile
	 * build an object based on an xml file
	 *
	 * @return mixed
	 * @author jph (jp.humblet@ulg.ac.be)
	**/
	static public function buildFromFile($kind, $file) {
		try {
			$object = simplexml_load_file($file, $kind);	
		} catch (Exception $e) {
			print_r($e);
		}
		return $object;
	}

	/**
	 * buildTask
	 * build a TaskBuilder for a TaskUID in Project ($p)
	 *
	 * @return TaskBuilder
	 * @author jph (jp.humblet@ulg.ac.be)
	**/
	static public  function buildTask($tid, $p) {
		$Task = $p->getTasks()->getByID($tid);
		$builder = simpleXML_load_string($Task->asXML() , "Tasks");
		return $builder;
	}
	
	/**
	 * newTimeEntry
	 * undocumented function
	 *
	 * @return TimeEntry
	 * @author jph (jp.humblet@ulg.ac.be)
	**/
	static public function newTimeEntry() {
		return new TimeEntry("<Entry/>");
	}
}

?>